<template>
  <div class="register-container">
    <div class="register-card">
      <!-- 注册标题 -->
      <h2 class="register-title">注册新账号</h2>

      <!-- 注册表单 -->
      <a-form layout="vertical" class="register-form">
        <!-- 用户名 -->
        <a-form-item label="用户名">
          <a-input 
            placeholder="设置您的用户名（3-20个字符）" 
            size="large"
            v-model:value="username"
          />
        </a-form-item>
        
        <!-- Email 输入 -->
        <a-form-item label="邮箱">
          <a-input 
            placeholder="请输入您的邮箱地址" 
            size="large"
            v-model:value="email"
          />
        </a-form-item>
        
        <!-- 密码 -->
        <div class="password-container">
          <label class="password-label">密码</label>
          <a-input-password
            class="password-input"
            placeholder="设置8-20位密码（字母+数字）"
            v-model:value="password"
          />
        </div>
        
        <!-- 确认密码 -->
        <div class="password-container">
          <label class="password-label">确认密码</label>
          <a-input-password
            class="password-input"
            placeholder="请再次输入密码"
            v-model:value="confirmPassword"
          />
        </div>
        
        <!-- 注册按钮 -->
        <a-button 
          type="primary" 
          size="large" 
          class="register-btn"
          @click="handleRegister"
        >
          注册账号
        </a-button>
        
        <!-- 登录链接 -->
        <div class="login-link">
          已有账号?
          <a @click="goToLogin">立即登录</a>
        </div>
      </a-form>

      <!-- 分隔线 -->
      <div class="divider">
        <span>或通过第三方账号登录</span>
      </div>

      <!-- 第三方注册 -->
      <div class="social-register">
        <a-button 
          type="primary" 
          class="social-btn wechat-btn"
        >
          <Icon icon="fa6-brands:weixin" />
         &nbsp;微信注册
        </a-button>
      </div>
      <div>
        <a-button 
          type="primary" 
          class="social-btn weibo-btn"
        >
        <Icon icon="fa6-brands:weibo" />
           &nbsp;微博注册
        </a-button>
      </div>
    </div>
  </div>
</template>

<script>
import { defineAsyncComponent } from 'vue';
// 修改组件名称以符合 ESLint 规则
export default {
  name: "UserRegister",
  components: { 
     Icon: defineAsyncComponent(() => import('@iconify/vue').then(m => m.Icon))
  },
  data() {
    return {
      username: "",
      email: "",
      password: "",
      confirmPassword: ""
    };
  },
  methods: {
    goToLogin() {
      // 这里添加导航到登录页的逻辑
      this.$router.push('/login');
    },
    handleRegister() {
      // 注册逻辑
      console.log('注册信息:', {
        username: this.username,
        email: this.email,
        password: this.password
      });
    }
  }
};
</script>

<style scoped>
.register-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #fff;
  padding: 20px;
}

.register-card {
  width: 100%;
  max-width: 420px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  padding: 40px;
}

.register-title {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 30px;
}

.register-form {
  margin-bottom: 30px;
}

.password-container {
  margin-bottom: 24px;
}

.password-label {
  font-weight: 500;
  color: #000;
  padding-bottom: 8px;
  font-size: 14px;
  display: block;
  margin-bottom: 5px;
}

.register-btn {
  width: 100%;
  height: 44px;
  font-size: 16px;
  margin-top: 30px;
  font-weight: 500;
  border-radius: 4pixel;
  background: linear-gradient(to right, #1e62d9, #3d8cff);
  border: none;
  box-shadow: 0 2px 6px rgba(52, 152, 219, 0.4);
}

.login-link {
  display: flex; 
  align-items: center; 
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 14px;
  color: #606266;
}

.social-register {
  margin: 15px 0;
}

.social-btn {
  width: 100%;
  height: 44px;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
}

.wechat-btn {
  background-color: #07bb07;
  border-color: #07bb07;
  color: white;
}

.wechat-btn:hover {
  background: linear-gradient(to right, #06a306, #0cc90c);
}

.weibo-btn {
  background-color: #ff8200;
  border-color: #ff8200;
  color: white;
}

.weibo-btn:hover {
  background: linear-gradient(to right, #e67400, #ff9a33);
}
.password-input{
  padding: 0 11px;
}

/* 输入框样式 */
:deep(.ant-input) {
  height: 32px !important;
  line-height: 32px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 4px;
  transition: border-color 0.3s;
}

:deep(.ant-input:focus) {
  border-color: #3d8cff;
  box-shadow: 0 0 0 2px rgba(61, 140, 255, 0.2);
}

/* 分隔线 */
.divider {
  position: relative;
  text-align: center;
  margin: 30px 0;
  color: #a0a9b6;
  font-size: 13px;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  height: 1px;
  width: 40%;
  background: linear-gradient(to right, transparent, #e0e6ed);
}

.divider::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  height: 1px;
  width: 40%;
  background: linear-gradient(to left, transparent, #e0e6ed);
}
</style>